﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.IO;


namespace BOM.SysAdmin
{
    public partial class LicenseDlg : Form
    {
        public LicenseDlg()
        {
            InitializeComponent();
        }

        private void onLoad(object sender, EventArgs e)
        {
            txtCode.Text = LicenseCheck.getHash(LicenseCheck.getHardID());
        }

        private void btnOpen_Click(object sender, EventArgs e)
        {
            OpenFileDialog dlg = new OpenFileDialog();
            dlg.Filter = "认证文件(*.dat)|*.dat";
            DialogResult rt = dlg.ShowDialog();
            if (rt == DialogResult.OK)
            {
               String srcFilePath = dlg.FileName;
               txtLicensePath.Text = srcFilePath;
               System.IO.File.Copy(srcFilePath, "license/license.dat", true);
               if (LicenseCheck.checkSignature())
               {
                   MessageBox.Show(this,"软件已成功激活!","提示");
                   this.Close();
               }
               else
                   MessageBox.Show(this,"认证文件无效!","提示");
            }
        }

    }
}
